/*
* Copyright (c) 2011 Connection Road.  All rights reserved.
* This program and the accompanying material are made available
* under the terms of the Eclipse Public Licnese v1.0 which is
* available at http://www.eclipse.org/legal/epl-v10.html
*/

using System;
using System.Drawing;
using System.Windows.Forms;
using CrSyncFilesForms.Utils;

namespace CrSyncFilesForms.Forms
{
    public partial class CrSyncUiHeaderOrganizer : UserControl
    {
        public CrSyncUiHeaderOrganizer()
        {
            InitializeComponent();

            Load += CallBackLoad;

            _defaultLocation = new Point(4, 4);
            _defaultSignInLocation = new Point(4, 92);
            _defaultPreLoaderLocation = new Point(4, 164);
            _defaultCloudInfoLocation = new Point(4, 236);
            _defaultCloudInfo2Location = new Point(4, 308);

        }

        private Point _defaultLocation;
        private Point _defaultPreLoaderLocation;
        private Point _defaultCloudInfoLocation;
        private Point _defaultCloudInfo2Location;
        private Point _defaultSignInLocation;

        private CrSyncUiHeaderOrganizerViewTypes _viewType;

        private void CallBackLoad(object sender, EventArgs e)
        {
            Height = 72;

            LabelCloudCapacity.ForeColor = CRSyncColors.CloudInfo;
            LabelCloudUserName.ForeColor = CRSyncColors.CloudInfo;
            LabelCloudUserName2.ForeColor = CRSyncColors.CloudInfo;
            LabelCloudSubscription.ForeColor = CRSyncColors.CloudInfo;
            LabelCloudSubscription2.ForeColor = CRSyncColors.CloudInfo;

            ViewType = CrSyncUiHeaderOrganizerViewTypes.SignIn;
        }

        public event LinkLabelLinkClickedEventHandler SignIn
        {
            add { LinkSignIn.LinkClicked += value; }
            remove { LinkSignIn.LinkClicked -= value; }
        }

        public event LinkLabelLinkClickedEventHandler RefreshUserInfo
        {
            add
            {
                LinkRefreshUserInfo.LinkClicked += value;
                LinkRefreshUserInfo2.LinkClicked += value;
            }
            remove
            {
                LinkRefreshUserInfo.LinkClicked -= value;
                LinkRefreshUserInfo2.LinkClicked -= value;
            }
        }

        public event LinkLabelLinkClickedEventHandler UpgradSubscription
        {
            add
            {
                LinkUpgradeSubscription.LinkClicked += value;
                LinkUpgradeSubscription2.LinkClicked += value;
            }
            remove
            {
                LinkUpgradeSubscription.LinkClicked -= value;
                LinkUpgradeSubscription2.LinkClicked -= value;
            }
        }

        public CrSyncUiHeaderOrganizerViewTypes ViewType
        {
            set
            {

                Reset();
                _viewType = value;
                switch (_viewType)
                {
                    case CrSyncUiHeaderOrganizerViewTypes.PreLoader:
                        PanelSignin.Visible = false;
                        PanelCloudInfo.Visible = false;
                        PanelCloudInfo2.Visible = false;
                        
                        PanelGetCloudPreLoader.Location = new Point(_defaultLocation.X, _defaultLocation.Y);
                        PanelGetCloudPreLoader.Visible = true;
                        break;
                    case CrSyncUiHeaderOrganizerViewTypes.CloudInfo:
                         PanelSignin.Visible = false;
                        PanelGetCloudPreLoader.Visible = false;
                        PanelCloudInfo2.Visible = false;


                        PanelCloudInfo.Location = new Point(_defaultLocation.X, _defaultLocation.Y);
                        PanelCloudInfo.Visible = true;
                        LabelCloudUserName.Visible = true;
                        LabelCloudSubscription.Visible = true;
                        LabelCloudUserName.Visible = true;

                       
                        break;
                    case CrSyncUiHeaderOrganizerViewTypes.CloudInfo2:
                        PanelSignin.Visible = false;
                        PanelGetCloudPreLoader.Visible = false;
                        PanelCloudInfo.Visible = false;

                        PanelCloudInfo2.Location = new Point(_defaultLocation.X, _defaultLocation.Y);
                        PanelCloudInfo2.Visible = true;
                        LabelCloudUserName2.Visible = true;
                        LabelCloudSubscription2.Visible = true;
                        WProgressBarBlue.Visible = true;
                        LinkRefreshUserInfo2.Visible = true;
                        LinkUpgradeSubscription2.Visible = true;
                        break;
                    default:

                        PanelGetCloudPreLoader.Visible = false;
                        PanelCloudInfo.Visible = false;
                        PanelCloudInfo2.Visible = false;

                        PanelSignin.Location = new Point(4,4);
                        PanelSignin.Visible = true;

                        PanelSignin.Visible = true;
                        LinkSignIn.Visible = true;
                        PanelSignTab.Visible = true;
                        break;
                }
            }

            get { return _viewType; }
        }

        public string UserName
        {
            set
            {
                LabelCloudUserName.Text = value;
                LabelCloudUserName2.Text = value;
            }

            get { return LabelCloudUserName.Text; }
        }

        public string SubscriptionInfo
        {
            set { LabelCloudSubscription.Text = value; }

            get { return LabelCloudSubscription.Text; }
        }

       public string StorageInfo
        {
            set { LabelCloudCapacity.Text = value; }
            get { return LabelCloudCapacity.Text; }
        }

        public bool ShowUpdgradeSubscription
        {
            set { LinkUpgradeSubscription.Visible = value; }
            get { return LinkUpgradeSubscription.Visible; }
        }

        public Color SubscriptionInfoForeColor
        {
            set { LabelCloudSubscription.ForeColor = value;  }
            get { return LabelCloudSubscription.ForeColor; }
        }

        public Font SubscriptionInfoFont
        {
            set { LabelCloudSubscription.Font = value; }
            get { return LabelCloudSubscription.Font; }
        }

        public string SubScriptionInfo2
        {
            set { LabelCloudSubscription2.Text = value; }
            get { return LabelCloudSubscription2.Text; }
        }

        public Color SubscriptionInfo2ForeColor
        {
            set { LabelCloudSubscription2.ForeColor = value; }
            get { return LabelCloudSubscription2.ForeColor; }
        }

        public Font SubscriptionInfo2Font
        {
            set { LabelCloudSubscription2.Font = value; }
            get { return LabelCloudSubscription2.Font; }
        }

        public string SignInLabel
        {
            set { LinkSignIn.Text = value; }
            get { return LinkSignIn.Text; }
        }

        public string StorageInfo2
        {
            set { WProgressBarBlue.ProgressInfo = value; }
            get { return WProgressBarBlue.ProgressInfo; }
        }

        public double PercentStorageUsed
        {
            set{ WProgressBarBlue.SetFraction( value );}
        }

        public void Reset()
        {
            PanelSignin.Location = new Point(_defaultSignInLocation.X, _defaultSignInLocation.Y);
            PanelCloudInfo.Location = new Point(_defaultCloudInfoLocation.X, _defaultCloudInfoLocation.Y);
            PanelCloudInfo2.Location = new Point(_defaultCloudInfo2Location.X, _defaultCloudInfo2Location.Y);
            PanelGetCloudPreLoader.Location = new Point(_defaultPreLoaderLocation.X, _defaultPreLoaderLocation.Y);

            PanelSignin.Visible = true;
            PanelCloudInfo.Visible = true;
            PanelCloudInfo2.Visible = true;
            PanelGetCloudPreLoader.Visible = true;
            
        }

        
    }
}
